﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Manson.WebServiceTest2
{
    
    public class OperateLog
    {
        public static void  AddLog(string log,string fileName="")
        {
            string path = $"{AppDomain.CurrentDomain.BaseDirectory}\\Log";
            if(!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string logPath = Path.Combine(path, $"{fileName}{DateTime.Now:yyy-MM-dd}.log");
            using StreamWriter streamWriter = new StreamWriter(logPath,true);
            streamWriter.AutoFlush=true;
            streamWriter.WriteLine($"[{DateTime.Now.ToString("HH:mm:ss fff")}] {log}");
            streamWriter.Close();

        }
    }
}
